<template>
	<view class="">
		<view class="list_cell">
			<view class="list_title">
				<image src="../../static/icon_no.png" mode=""></image>
				未完成
			</view>
			<view class="uni-list">
				<view class="uni-list-cell" v-for="(item,index) in data.rows" :key="index" @click="gopage(item.id,item.title,item.score,item.num,0)">
					<view class="uni-list-cell-navigate uni-navigate-right">
						{{item.title}} 
						<view class="right_text"><image src="../../static/icon_sigh.png" mode=""></image><text>未做</text></view>
					</view>
				</view>
			</view>
			<!-- <view class="uni-tab-bar-loading">
				<uni-load-more :loadingType="loadingType" :contentText="loadingText"></uni-load-more>
			</view> -->
		</view>
		<view class="list_cell">
			<view class="list_title">
				<image src="../../static/icon_yes.png" mode=""></image>
				已完成
			</view>
			<view class="uni-list">
				<view class="uni-list-cell" v-for="(item,index) in data2.rows" :key="index" @click="gopage(item.id,item.title,item.score,item.num,1)">
					<view class="uni-list-cell-navigate uni-navigate-right">
						{{item.title}}
						<view class="right_text"><text>了解详情</text></view>
					</view>
				</view>
<!-- 				<view class="uni-list-cell">
					<view class="uni-list-cell-navigate uni-navigate-right">
						安全培训
						<view class="right_text"><text>了解详情</text></view>
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	// import uniLoadMore from '@/components/uni-load-more.vue';
	import API from '../../common/api.js';
	export default {
		// components: {
		// 	uniLoadMore
		// },
		data() {
			return {
				userid:uni.getStorageSync('userid'),
				page:1,
				rows:20,
				data:[],//已完成
				data2:[],//未完成
				loadingText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多数据了"
				},
				loadingType:0
			}
		},
		onLoad: function() {
			// this.myUndoQues();
			if(!uni.getStorageSync("userid")||!uni.getStorageSync("deptid")){
				// uni.redirectTo({
				// 	url:"../login/login"
				// })
			}
		},
		onShow(){
			this.myUndoQues();
		},
		onPullDownRefresh(){
			this.page=1;
			this.data=[];//已完成
			this.data2=[];//未完成
			this.myUndoQues();
		},
		methods:{
			gopage(id,title,score,num,stu){
				uni.navigateTo({
					url:'./review?id='+id+"&title="+title+id+"&score="+score+"&num="+num+"&stu="+stu
				})
			},
			myUndoQues(){
				var _this = this;
				uni.request({//已完成
					url:API.myUndoQues,
					method:"GET",
					data:{
						userid:this.userid,
						page:_this.page,
						rows:_this.rows
					},
					header:API.get_head(),
					success: (res) => {
						_this.data = res.data;
						uni.stopPullDownRefresh();
					},
					fail: () => {
						uni.showToast({
							title:"加载失败",
							icon:'none'
						})
						uni.stopPullDownRefresh();
					}
				})
				uni.request({//未完成
					url:API.myDoneQues,
					method:"GET",
					data:{
						userid:this.userid,
						page:_this.page,
						rows:_this.rows
					},
					header:API.get_head(),
					success: (res) => {
						_this.data2 = res.data;
					},
					fail: () => {
						uni.showToast({
							title:"加载失败",
							icon:'none'
						})
					}
				})
			},
// 			onReachBottom(){
// 				var _this = this;
// 				if(_this.data.page ==_this.data.total){
// 					uni.showToast({
// 						icon:"none",
// 						title:"最后一页啦",
// 					})
// 					return false;
// 				}
// 				this.loadingType =1;
// 				uni.request({
// 					url:API.myUndoQues,
// 					method:"GET",
// 					data:{
// 						userid:this.userid,
// 						page:_this.data.page+1,
// 						rows:_this.rows
// 					},
// 					header:API.get_head(),
// 					success: (res) => {
// 						_this.data.page=_this.data.page+1;
// 						_this.data.rows = _this.data.rows.concat(res.data.rows);
// 						this.loadingType = 0;
// 					},
// 					fail: () => {
// 						uni.showToast({
// 							title:"加载失败",
// 							icon:'none'
// 						})
// 					}
// 				})
// 			}
		}
	}
	
	
</script>

<style>
	.list_cell{
		margin-bottom:20upx;
	}
	.list_title{
		padding:45upx 24upx;
		color: #333333;
		font-size:32upx;
		background:#FFFFFF;
		font-weight:bold;
		border:1upx solid #e5e5e5;
	}
	.list_title image{
		width:50upx;
		height:50upx;
		vertical-align: middle;
		margin-right:30upx;
	}
	.uni-list:before{
		display:none;
	}
	.uni-list:after{
		display:none;
	}
	.uni-list-cell:before{
		display:none;
	}
	.uni-list-cell:after{
		display:none;
	}
	.uni-list-cell{
		font-size:30upx;
		color:#333333;
		padding:50upx 24upx;
		border-bottom:1upx solid #e5e5e5;
	}
	.uni-list-cell:last-child{
		border:none;
	}
	.uni-list-cell-navigate{
		padding: 0;
	}
	.uni-list-cell-navigate.uni-navigate-right:after {
		right: 0;
		top: 50%;
		font-size:30upx;
	}
	.right_text{
		float:right;
	}
	.right_text image{
		width:40upx;
		height:40upx;
		vertical-align:middle;
		margin-top:-5rpx;
	}
	.right_text text{
		color:#067aee;
		font-size: 30upx;
		padding-left:28upx;
		padding-right:77upx;
	}
</style>
